package com.ruoyi.web.controller.account;

import com.ruoyi.account.domain.DebtVO;
import com.ruoyi.account.service.DebtService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/debt")
public class DebtController {

    @Autowired
    private DebtService debtService;

    /**
     * 获取账本的债务结算方案
     */
    @GetMapping("/settlement")
    @Anonymous
    public AjaxResult getDebtSettlement(@RequestParam Long ledgerId) {
        List<DebtVO> debts = debtService.calculateDebts(ledgerId);
        return AjaxResult.success(debts);
    }
}